package com.my.handlers;

import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;
import com.jfinal.kit.StrKit;

public class ResourceHandler extends Handler
{
	private Pattern skipedUrlPattern;

	public ResourceHandler(String skipedUrlRegx) {
		if (StrKit.isBlank(skipedUrlRegx))
			throw new IllegalArgumentException("The para excludedUrlRegx can not be blank.");
		skipedUrlPattern = Pattern.compile(skipedUrlRegx);
	}

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		if (skipedUrlPattern.matcher(target).matches()) {
			System.out.println("正则匹配...");
			return;
		} else
			next.handle(target, request, response, isHandled);
	}
}
